package com.cn.lycss.servlet.user;

import com.alibaba.fastjson.JSONObject;
import com.cn.lycss.model.ResultModel;
import com.cn.lycss.model.UserModel;
import com.cn.lycss.service.UserService;
import com.cn.lycss.service.impl.UserServiceImpl;
import com.cn.lycss.util.Tool;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/back/user/delete")
public class UserDeleteServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        String id=req.getParameter("id");
        UserModel userModel=new UserModel();
        userModel.setId(Tool.aa(id));
        //        3.创建服务逻辑层
        UserService userService = new UserServiceImpl();
        //        4.接收服务逻辑层返回信息

        ResultModel resultModel = userService.delete(userModel);
        //        5.将信息返回给前端
        resp.getWriter().println(JSONObject.toJSONString(resultModel));
    }
}
